/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package objects;

import graphic.Color;
import graphic.Graphic;

/**
 *
 * @author nicra
 */
public class Cross {
    public Color color;
    public float size=0;
    public float w;
    public float pos[] = new float[3];
    
    private Triangle[] t = new Triangle[4];

    public void draw(){
        if(size==0) return;
        Graphic.e.setColor(color);
        for(int i=0;i<t.length;++i)
            Graphic.e.drawTTrans(t[i],pos[0],pos[1],pos[2]);
    }
    
    public void resize(float size,float w){
        this.size=size;
        this.w=w;
        gen();
    }
    
    public void move(float x,float y,float z){
        pos[0]=x;
        pos[1]=y+0.1f;
        pos[2]=z;
    }
    
    public void set(float x,float y,float z,float size,float w,Color c){
        pos[0]=x;
        pos[1]=y+0.1f;
        pos[2]=z;
        color=c;
        this.size=size;
        this.w=w;
        gen();
    }    
    
    public void gen(){
        float hsize=size/2;
        float hw=w/2;
        t[0]=new Triangle( +hsize,0,+hw,
                           +hsize,0,-hw,                          
                           -hsize,0,-hw);
        t[1]=new Triangle( +hsize,0,+hw,
                           -hsize,0,-hw,
                           -hsize,0,+hw);
        
        
        t[2]=new Triangle( +hw,0,-hsize,
                           -hw,0,-hsize,
                           +hw,0,+hsize);
        t[3]=new Triangle( +hw,0,+hsize,
                           -hw,0,-hsize,
                           -hw,0,+hsize);
        
        for(int i=0;i<t.length;++i)
            t[i].calcNormal();
        
    }
}
